import request from "@/utils/request";

// 接口返回结构固定
// data 的类型, 传进来
type Result<T = undefined> = {
    code: string,
    message: string,
    data: T
}

// 地址列表
export function ress(userid: string) {
    return request.get<any, Result>('/address/list', {
        params: {
            userid,
        }
    })
}

//默认地址
export function defaultAddress(userid: string) {
    return request.post<any, Result>('/address/defaultAddress', {
        userid,
    })
}

//  添加地址
export function addmap(
    userid: string,
    name: string, tel: string,
    province: string, city: string,
    county: string,
    addressDetail: string,
    isDefault: Boolean
) {
    return request.post<any, Result>('/address/add', {
        userid,
        name,
        tel,
        province,
        city,
        county,
        addressDetail,
        isDefault
    })
}

// 修改地址
export function update(data: any) {
    return request.post<any, Result>('/address/update',
        data
    )
}


// 删除地址
export function ressdelete(addressid: string) {
    return request.post<any, Result>('/address/delete', {
        addressid
    })
}